import mongoose from 'mongoose';
import { formatDateByNow } from '~/utils/util.date';

export interface IClientUser extends mongoose.Document {
	avatar: string;
	username: string;
	password: string;
	gender: string;
	email: string;
	birthday: string;
	createdAt?: string;
	updatedAt?: string;
}

// 客户端用户
const ClientUserSchema = new mongoose.Schema<IClientUser>(
	{
		avatar: {
			type: String,
		},
		username: {
			type: String,
			required: true,
			unique: true,
		},
		password: {
			type: String,
			required: true,
		},
		gender: {
			type: String,
			enum: ['male', 'female'],
			required: true,
		},
		email: {
			type: String,
			required: true,
			unique: true,
		},
		birthday: {
			type: String,
		},
		createdAt: {
			type: String,
			default: formatDateByNow(),
		},
		updatedAt: {
			type: String,
			default: formatDateByNow(),
		},
	},
	{
		collection: 'client_users',
	}
);

export const ClientUserModel = mongoose.model('ClientUser', ClientUserSchema);
